﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;

namespace SnowLotus.Canvas
{
    public class SL2Path
    {

       

       


        public Path CreateLinePath(double startX, double startY, double endX, double endY)
        {
            Path path = new Path
            {
                Stroke = Brushes.Red,
                StrokeThickness = 1,
                StrokeDashArray = new DoubleCollection(new double[] { 4, 4 })
            };

            Manager.AddShape(path);

            PathGeometry pathGeometry = new PathGeometry();
            PathFigure pathFigure = new PathFigure
            {
                StartPoint = new Point(startX, startY)
            };
            pathFigure.Segments.Add(new LineSegment(new Point(endX, endY), true));
            pathGeometry.Figures.Add(pathFigure);

            path.Data = pathGeometry;
            return path;
        }


        public Path CreateRectanglePath(double x, double y, double width, double height)
        {
            Path path = new Path
            {
                Stroke = Brushes.Red,
                StrokeThickness = 1
            };
            Manager.AddShape(path);
            PathGeometry pathGeometry = new PathGeometry();
            PathFigure pathFigure = new PathFigure
            {
                StartPoint = new Point(x, y)
            };
            pathFigure.Segments.Add(new LineSegment(new Point(x + width, y), true));
            pathFigure.Segments.Add(new LineSegment(new Point(x + width, y + height), true));
            pathFigure.Segments.Add(new LineSegment(new Point(x, y + height), true));
            pathFigure.Segments.Add(new LineSegment(new Point(x, y), true));
            pathGeometry.Figures.Add(pathFigure);

            path.Data = pathGeometry;
            return path;
        }

        //public Path CreateCirclePath(double centerX, double centerY, double radius)
        //{
        //    Path path = new Path
        //    {
        //        Stroke = Brushes.Red,
        //        StrokeThickness = 1
        //    };
        //    Manager.AddShape(path);
        //    PathGeometry pathGeometry = new PathGeometry();
        //    PathFigure pathFigure = new PathFigure
        //    {
        //        StartPoint = new Point(centerX, centerY - radius)
        //    };
        //    pathFigure.Segments.Add(new ArcSegment(new Point(centerX + radius, centerY), new Size(radius, radius), 0, false, SweepDirection.Clockwise, true));
        //    pathFigure.Segments.Add(new ArcSegment(new Point(centerX, centerY - radius), new Size(radius, radius), 0, false, SweepDirection.Clockwise, true));
        //    pathGeometry.Figures.Add(pathFigure);

        //    path.Data = pathGeometry;
        //    return path;
        //}

        public Path CreateTrianglePath(double startX, double startY)
        {
            Path path = new Path
            {
                Stroke = Brushes.Red,
                StrokeThickness = 1
            };
            Manager.AddShape(path);
            PathGeometry pathGeometry = new PathGeometry();
            PathFigure pathFigure = new PathFigure
            {
                StartPoint = new Point(startX, startY)
            };
            pathFigure.Segments.Add(new LineSegment(new Point(startX + 50, startY), true));
            pathFigure.Segments.Add(new LineSegment(new Point(startX + 25, startY + 50), true));
            pathFigure.Segments.Add(new LineSegment(new Point(startX, startY), true));
            pathGeometry.Figures.Add(pathFigure);

            path.Data = pathGeometry;
            return path;
        }

        public Path CreateBezierPath(double startX, double startY)
        {
            Path path = new Path
            {
                Stroke = Brushes.Red,
                StrokeThickness = 1
            };
            Manager.AddShape(path);
            PathGeometry pathGeometry = new PathGeometry();
            PathFigure pathFigure = new PathFigure
            {
                StartPoint = new Point(startX, startY)
            };
            pathFigure.Segments.Add(new BezierSegment(new Point(startX + 50, startY - 50), new Point(startX + 100, startY + 50), new Point(startX + 150, startY), true));
            pathGeometry.Figures.Add(pathFigure);

            path.Data = pathGeometry;
            return path;
        }
    }


}

